﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RSS de EstasEnPosse.com.ar</title>
<link href="../../EstilosPHP.css" rel="stylesheet" type="text/css" />

</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="40%" bgcolor="#FDFDFD"><div align="left"><img src="../../IMAGENES/LogoMaster.jpg" width="274" height="128" /></div></td>
    <td width="60%" bgcolor="#FDFDFD"><div align="left"><img src="../../IMAGENES/justiniano.jpg" width="125" height="229" /></div></td>
  </tr>
</table>
<p>&nbsp;</p>
<p><span class="EstiloNormal">
  <?php 

function sanear_string($string)
{
 
    $string = trim($string);
    //Esta parte se encarga de eliminar cualquier caracter extraño
   
 //return $string;
 	$string = str_replace(array("&ntilde;"), 'ñ',$string);
  	$string = str_replace(array("&Ntilde;"), 'Ñ',$string);
 	$string = str_replace(array("&aacute;"), 'á',$string);
    $string = str_replace(array("&Aacute;"), 'Á',$string);
	$string = str_replace(array("&eacute;"), 'é',$string);
	$string = str_replace(array("&Eacute;"), 'É',$string);
	$string = str_replace(array("&iacute;"), 'í',$string);
	$string = str_replace(array("&Iacute;"), 'Í',$string);
	$string = str_replace(array("&oacute;"), 'ó',$string);
	$string = str_replace(array("&Oacute;"), 'Ó',$string);
	$string = str_replace(array("&uacute;"), 'ú',$string);
	$string = str_replace(array("&Uacute;"), 'Ú',$string);
		   
	$string = str_replace(array("&nbsp;"), ' ',$string);
    $string = str_replace(array("&iquest;"), '¿',$string);
    $string = str_replace(array("&rdquo;"), '"',$string);
    $string = str_replace(array("&hellip;"), '...',$string);
    $string = str_replace(array("&ldquo;"), '"',$string);
    $string = str_replace(array("&ordm;"), 'º',$string);
	$string = str_replace(array("&iexcl;"), '¡',$string);
	$string = str_replace(array("&Uuml;"), 'Ü',$string);
	$string = str_replace(array("&uuml;"), 'ü',$string);
	$string = str_replace(array("&ordf;"), 'ª',$string);
	$string = str_replace(array("&ndash;"), '-',$string);
	$string = str_replace(array("&deg;"), '°',$string);
	$string = str_replace(array("&lt;"), '<',$string);
	$string = str_replace(array("&gt;"), '>',$string);
	$string = str_replace(array("&frasl;"), '/',$string);
	$string = str_replace(array("&reg;"), '®',$string);
	
	
 $string = str_replace(
    /*   array("<b>","</b>","<a href=","</a","</a>","<em>","</em>","¨","~","<p>","</p>","</strong>","<strong>","<br>","</br>","<br","</br","<span","<span style","</span>","·","^", "`","¨", "´","<img","/>","<img src=","color:","#","<div>","</div>","<ul>","</ul>","<li>","<li","</li>","style=&quot; ff6600;&quot;>","style",">","=","ff6600","ff9900","FF6600","FF9900","&quot;","<p align'right'","<p align","'right'","'left'","<p","<p 'text-align: center;'","<iframe src","</iframe>","</iframe","height","width",), '',$string);
		 */
		  array("<a href=","</a","</a>","<em>","</em>","¨","~","<p>","</p>","</strong>","<strong>","<br>","</br>","<br","</br","<span","<span style","</span>","·","^", "`","¨", "´","<img","<img src=","color:","#","<div>","</div>","<ul>","</ul>","<li>","<li","</li>","style=&quot; ff6600;&quot;>","style",">","=","ff6600","ff9900","FF6600","FF9900","&quot;","<p align'right'","<p align","'right'","'left'","<p","<p 'text-align: center;'","<iframe src","</iframe>","</iframe","height","width",), '',$string);
 return $string; 
}
  
  $hora = date("h:i:s");
  $dia = date("d");
  $nombreDia = date("I");
  $mes = date("m");
  $anio = date("Y");
  $fecha = $anio."-".$mes."-".$dia;
  $hasta = date("d/m/Y") + 15;
  
$fechaCreado = date("Y/m/d - h:i:s");
echo "Último Creado: a las ".$hora." Dia: ".$fecha."<br><br>";

echo "Archivo: <strong><a href='http://www.estasenposse.com/RSS/RSSPublicidadEstasEnPosse.xml'>RSSEstasEnPosse.xml</a></strong> ";
$buffer = '<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0"><channel>';
	$buffer = $buffer.'<title>RSS Publicidad EstasEnPosse.com</title>';
	$buffer = $buffer.'<description>Publicidades de EstasEnPosse.com</description>';
	$buffer = $buffer.'<link>http://www.EstasEnPosse.com/</link>';
	$buffer = $buffer.'<lastBuildDate>'.$fechaCreado.'</lastBuildDate>';
	$buffer = $buffer.'<pubDate>Tue, 13 May 2014 16:45:00 +0000</pubDate>';	

include ("../../conexion.php");
$db = conectaDb();
$dbCliente = $dbDb . ".CLIENTE";  // Nombre de la tabla
//PRIMER CONSULTA, NOTA PRINCIPAL
$consulta = "SELECT * FROM $dbCliente WHERE ID > 0 ORDER BY ID ASC"; 
try {
$result = $db->prepare($consulta,array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
$result->execute();
if (!$result) {
    print "<p>Error en la consulta.</p>\n";
} else {
  
    foreach ($result as $array) {
         
        
		  $ID = $array['ID'];
		  $nombre = sanear_string($array['NOMBRE']);
		  $direccion = sanear_string($array['DIRECCION']);
		  $mail = $array['MAIL'];
		  $telefono = $array['CARACTERISTICA'] . $array['TELEFONO'];
		  $link = $array['LINK'];
		  $facebook = $array['NOTA'];
		  $archivo = $array['ARCHIVO'];
		  $imagen = $array['IMAGEN'];
		  $logo = $array['LOGO'];
		 
			 //ARMAR EL RSS
	$buffer = $buffer.'<item>';	
	$buffer = $buffer.'<id>'.$ID.'</id>';
	$buffer = $buffer.'<nombre>'.$nombre.'</nombre>';
	$buffer = $buffer.'<direccion>'.$direccion.'</direccion>';
	$buffer = $buffer.'<mail>'.$mail.'</mail>';
	$buffer = $buffer.'<telefono>'.$telefono.'</telefono>';
	$buffer = $buffer.'<link>'.$link.'</link>';
	$buffer = $buffer.'<facebook>'.$facebook.'</facebook>';
	if ($archivo <> "" ){ $buffer = $buffer.'<archivo>'.$archivo.'</archivo>';  }
	if ($imagen <> "" ){ $buffer = $buffer.'<imagen>'.$imagen.'</imagen>';  }
	if ($logo <> "" ){ $buffer = $buffer.'<logo>'.$logo.'</logo>';  }
	$buffer = $buffer.'</item>';
	
			 	 }
			}
  } catch (PDOException $e) {
    print $e->getMessage();
  }		
		
		
  $buffer = $buffer.'</channel></rss>';
  //$file=fopen("RSSPublicidadEstasEnPosse.xml","w+"); 
  $file=fopen("../../RSS/rsspublicidadestasenposse.xml","w+"); 
  fwrite ($file,$buffer); 
  fclose($file); 

//echo $buffer;

?> 
</span></p>
<p class="EstiloNormal">Publis de EstasEnPosse.com: </p>
<p><span class="EstiloNormal">Archivo de Noticias RSS:</span>
  <input name="textfield" type="text" id="textfield" value="http://www.estasenposse.com.ar/RSS/RSSPublicidadEstasEnPosse.xml" size="70" />
</p>
<form id="form1" name="form1" method="post" action="">
  <label for="textarea"></label>
  <textarea name="textarea" id="textarea" cols="90" rows="20"><? echo $buffer;?></textarea>
</form>
<p>&nbsp;</p>
<p>
  <span class="EstiloNormal">
</span></p>

</body>
</html>